package data_structures_and_algorithms.two_point;

// https://leetcode.cn/problems/container-with-most-water/ 11、盛水最多的容器
public class _11_maxArea_water {



    // 题目保证height长度大于等于2

    public int maxArea(int[] height) {
        int max = 0, head = 0, tail = height.length - 1;
        while (head < tail){
            if (height[tail] < height[head]){
                max = Math.max(max, (tail - head) * height[tail]);
                tail--;
            }else {
                max = Math.max(max, (tail - head) * height[head]);
                head++;
            }
        }
        return max;
    }




}
